<?php
/**
 * Created by PhpStorm.
 * Author: sitenv@aliyun.com
 * CreateTime: 2021/07/11 16:09
 * Blog：www.myblogs.xyz
 */

namespace app\common\service;


use app\common\model\Menu;

class RequestLogService
{
    public static function saveLog($menu_id, $adminData, $url)
    {
        if (!empty($menu_id)){
            $menu_model = new Menu();
            $title = $menu_model->where('menu_id', $menu_id)->value('menu_name');
            $param = input('param.');
            if (!empty($param)){
                $request_data = [
                    'admin_id'=>$adminData['adminId'],
                    'title'=>$title,
                    'url'=>$url,
                    'param'=>json_encode($param),
                    'account'=>$adminData['account'],
                    'create_time'=>NEW_TIME,
                    'create_ip'=>get_client_ip()
                ];
                $request_log = new \app\common\model\RequestLog();
                $request_log->insert($request_data);
            }
        }
    }
}